import { Callout } from 'nextra/components'

# Advanced

This guide covers advanced configuration options for self-hosting Rybbit.

## Setup Script Options

The setup script supports several options:

```bash
./setup.sh <domain_name> [options]
```

Available options:
- `--no-webserver`: Disable the built-in Caddy webserver
- `--backend-port <port>`: Set custom host port for backend (default: 3001)
- `--client-port <port>`: Set custom host port for client (default: 3002)
- `--help`: Show help message

Examples:
```bash
# Custom ports with built-in webserver
./setup.sh tracking.example.com --backend-port 8080 --client-port 8081

# Custom ports with your own webserver
./setup.sh tracking.example.com --no-webserver --backend-port 8080 --client-port 8081
```

<Callout type="info">
  When you specify custom ports, only the host port mapping changes. Inside the Docker containers, the services still use ports 3001 and 3002.
</Callout>

## Using Your Own Web Server

If you prefer to use your own web server (such as Nginx or Apache) instead of the built-in Caddy server, you can use the `--no-webserver` flag:

```bash
./setup.sh your.domain.name --no-webserver
```

This will:
- Not start the Caddy container
- Expose the backend service on host port 3001 (or your custom port)
- Expose the client service on host port 3002 (or your custom port)

You'll need to configure your web server to proxy requests to these services. Here's an example Nginx configuration:

```nginx
server {
    listen 80;
    server_name your.domain.name;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name your.domain.name;

    # SSL configuration (using Let's Encrypt)
    ssl_certificate /etc/letsencrypt/live/your.domain.name/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your.domain.name/privkey.pem;

    # API requests - adjust port if you customized it
    location /api/ {
        proxy_pass http://localhost:3001;  # or your custom port
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # Client app - adjust port if you customized it
    location / {
        proxy_pass http://localhost:3002;  # or your custom port
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
```

For a detailed step-by-step guide on setting up Nginx with SSL certificates using Certbot, see our [Nginx Setup Guide](/docs/self-hosting-nginx).
